package com.zxct.wyserver.interactive;

import android.app.Activity;
import android.webkit.JavascriptInterface;

import com.zxct.wyserver.util.SPUtils;

/**
 * Created by lanyu on 2018/1/29.
 */

public class JavaScriptInterface {

    public Activity mActivity;
    public SPUtils sp;

    public JavaScriptInterface(Activity mActivity) {
        this.mActivity = mActivity;
    }

    //提供JS存储SP的方法
    @JavascriptInterface
    public void setGlobalString(final String spName, final String key, final String value) {
        sp = new SPUtils(mActivity, spName);
        sp.putString(key, value);
    }

    //提供JS根据key获取值的方法
    @JavascriptInterface
    public String getGlobalString(final String spName, final String key) {
        sp = new SPUtils(mActivity, spName);
        return sp.getString(key);
    }

    //finish
    @JavascriptInterface
    public void tofinish() {
        mActivity.finish();
    }

    //其他方法。。。
}
